

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using System.Drawing;
using MonoTouch.ObjCRuntime;

namespace ComBrowser
{



	public class BookCollection : List<Book>
	{

		private static BookCollection _singleton = null; 
		private static object locker = new object();
		
		public static BookCollection Instance ()
		{
			lock (locker) {
				if (_singleton == null)
					_singleton = new BookCollection ();
		
			return _singleton;
			}
		}
		
		public List<Book> GetTestmentBooks(Testament testament)
		{
		    var q = from b in this 
				where b.Testament==testament
					select b;
			
			return q.ToList();
		}
		
		private BookCollection ()
		{ 
			Populate ();
		}

		private void Populate ()
		{
			BookType b = BookType.Penteteuch;
			UIColor c = UIColor.FromRGB (214, 204, 134);
			Testament t = Testament.New;
			this.Add (new Book {Chapters=50, OneBasedBookID = 1, Long = "Genesis", Short = "Gen", Color = c,   BookType = b });
			this.Add (new Book {Chapters=40, OneBasedBookID = 2, Long = "Exodus", Short = "Exo", Color = c, BookType = b });
			this.Add (new Book {Chapters=27, OneBasedBookID = 3, Long = "Leviticus", Short = "Lev", Color = c, BookType = b });
			this.Add (new Book {Chapters=36, OneBasedBookID = 4, Long = "Numbers", Short = "Num", Color = c, BookType = b });
			this.Add (new Book {Chapters=34, OneBasedBookID = 5, Long = "Deuteronomy", Short = "Deu", Color = c, BookType = b });

		    b = BookType.Blue;
			c = UIColor.FromRGB (126, 125, 134);
			this.Add (new Book {Chapters=24, OneBasedBookID = 6, Long = "Joshua", Short = "Jos", Color = c, BookType = b });
			this.Add (new Book {Chapters=21, OneBasedBookID = 7, Long = "Judges", Short = "Judg", Color = c, BookType = b });
			this.Add (new Book {Chapters=4, OneBasedBookID = 8, Long = "Ruth", Short = "Rth", Color = c, BookType = b });
			this.Add (new Book {Chapters=31, OneBasedBookID = 9, Long = "1 Samuel", Short = "1Sa", Color = c, BookType = b });
			this.Add (new Book {Chapters=24, OneBasedBookID = 10, Long = "2 Samuel", Short = "2Sa", Color = c, BookType = b });
			this.Add (new Book {Chapters=22, OneBasedBookID = 11, Long = "1 Kings", Short = "1Ki", Color = c, BookType = b });
			this.Add (new Book {Chapters=25, OneBasedBookID = 12, Long = "2 Kings", Short = "2Ki", Color = c, BookType = b });
			this.Add (new Book {Chapters=29, OneBasedBookID = 13, Long = "1 Chronicles", Short = "1Ch", Color = c, BookType = b });
			this.Add (new Book {Chapters=36, OneBasedBookID = 14, Long = "2 Chronicles", Short = "2Ch", Color = c, BookType = b });
			this.Add (new Book {Chapters=10, OneBasedBookID = 15, Long = "Ezra", Short = "Eza", Color = c, BookType = b });
			this.Add (new Book {Chapters=13, OneBasedBookID = 16, Long = "Nehemiah", Short = "Neh", Color = c, BookType = b });
			this.Add (new Book {Chapters=10, OneBasedBookID = 17, Long = "Esther", Short = "Est", Color = c, BookType = b });

			b = BookType.White;
			c = UIColor.FromRGB (255, 255, 255);
			this.Add (new Book {Chapters=42, OneBasedBookID = 18, Long = "Job", Short = "Job", Color = c, BookType = b });
			this.Add (new Book {Chapters=150, OneBasedBookID = 19, Long = "Psalm", Short = "Psa", Color = c, BookType = b });
			this.Add (new Book {Chapters=31, OneBasedBookID = 20, Long = "Proverbs", Short = "Pro", Color = c, BookType = b });
			this.Add (new Book {Chapters=12, OneBasedBookID = 21, Long = "Ecclesiastes", Short = "Ecc", Color = c, BookType = b });
			this.Add (new Book {Chapters=8, OneBasedBookID = 22, Long = "Song of Solomon", Short = "SS", Color = c, BookType = b });
			
			b = BookType.MajorProphets;
			c = UIColor.FromRGB (96, 111, 75);
			this.Add (new Book {Chapters=66, OneBasedBookID = 23, Long = "Isaiah", Short = "Isa", Color = c, BookType = b });
			this.Add (new Book {Chapters=52, OneBasedBookID = 24, Long = "Jeremiah", Short = "Jer", Color = c, BookType = b });
			this.Add (new Book {Chapters=5, OneBasedBookID = 25, Long = "Lamentations", Short = "Lam", Color = c, BookType = b });
			this.Add (new Book {Chapters=48, OneBasedBookID = 26, Long = "Ezekiel", Short = "Ezk", Color = c, BookType = b });
			this.Add (new Book {Chapters=12, OneBasedBookID = 27, Long = "Daniel", Short = "Dan", Color = c, BookType = b });
			
			b = BookType.MinorProphets;
			c = UIColor.FromRGB (144, 97, 51);
			this.Add (new Book {Chapters=14, OneBasedBookID = 28, Long = "Hosea", Short = "Hos", Color = c, BookType = b });
			this.Add (new Book {Chapters=3, OneBasedBookID = 29, Long = "Joel", Short = "Joe", Color = c, BookType = b });
			this.Add (new Book {Chapters=9, OneBasedBookID = 30, Long = "Amos", Short = "Amo", Color = c, BookType = b });
			this.Add (new Book {Chapters=1, OneBasedBookID = 31, Long = "Obadiah", Short = "Obd", Color = c, BookType = b });
			this.Add (new Book {Chapters=4, OneBasedBookID = 32, Long = "Jonah", Short = "Jon", Color = c, BookType = b });
			this.Add (new Book {Chapters=7, OneBasedBookID = 33, Long = "Micah", Short = "Mic", Color = c, BookType = b });
			this.Add (new Book {Chapters=3, OneBasedBookID = 34, Long = "Nahum", Short = "Nah", Color = c, BookType = b });
			this.Add (new Book {Chapters=3, OneBasedBookID = 35, Long = "Habakkuk", Short = "Hab", Color = c, BookType = b });
			this.Add (new Book {Chapters=3, OneBasedBookID = 36, Long = "Zephaniah", Short = "Zep", Color = c, BookType = b });
			this.Add (new Book {Chapters=2, OneBasedBookID = 37, Long = "Haggai", Short = "Hag", Color = c, BookType = b });
			this.Add (new Book {Chapters=14, OneBasedBookID = 38, Long = "Zechariah", Short = "Zch", Color = c, BookType = b });
			this.Add (new Book {Chapters=4, OneBasedBookID = 39, Long = "Malachi", Short = "Mal", Color = c, BookType = b });
			
			
			b = BookType.Gospel;
			c = UIColor.FromRGB (255, 255, 255);
			this.Add (new Book {Chapters=28, OneBasedBookID = 40, Long = "Matthew", Short = "Mat", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=16, OneBasedBookID = 41, Long = "Mark", Short = "Mar", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=24, OneBasedBookID = 42, Long = "Luke", Short = "Luk", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=21, OneBasedBookID = 43, Long = "John", Short = "Jn", Color = c, BookType = b, Testament = t });
			
			b = BookType.Historical;
			c = UIColor.FromRGB (126, 125, 134);
			this.Add (new Book {Chapters=28, OneBasedBookID = 44, Long = "Acts", Short = "Act", Color = c, BookType = b, Testament = t });
			
			b = BookType.Yellow;
			c = UIColor.FromRGB (211, 200, 123);
			this.Add (new Book {Chapters=16, OneBasedBookID = 45, Long = "Romans", Short = "Rom", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=16, OneBasedBookID = 46, Long = "1 Corinthians", Short = "1Co", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=13, OneBasedBookID = 47, Long = "2 Corinthians", Short = "2Co", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=6, OneBasedBookID = 48, Long = "Galatians", Short = "Gal", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=6, OneBasedBookID = 49, Long = "Ephesians", Short = "Eph", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=4, OneBasedBookID = 50, Long = "Philippians", Short = "Phi", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=4, OneBasedBookID = 51, Long = "Colossians", Short = "Col", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=5, OneBasedBookID = 52, Long = "1 Thessalonians", Short = "1Th", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=3, OneBasedBookID = 53, Long = "2 Thessalonians", Short = "2Th", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=6, OneBasedBookID = 54, Long = "1 Timothy", Short = "1Ti", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=4, OneBasedBookID = 55, Long = "2 Timothy", Short = "2Ti", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=3, OneBasedBookID = 56, Long = "Titus", Short = "Tit", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=1, OneBasedBookID = 57, Long = "Philemon", Short = "Phm", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=13, OneBasedBookID = 58, Long = "Hebrews", Short = "Heb", Color = c, BookType = b, Testament = t });
			
			b = BookType.Green;
			c = UIColor.FromRGB (86, 106, 69);
			this.Add (new Book {Chapters=5, OneBasedBookID = 59, Long = "James", Short = "Jam", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=5, OneBasedBookID = 60, Long = "1 Peter", Short = "1Pe", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=3, OneBasedBookID = 61, Long = "2 Peter", Short = "2Pe", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=5, OneBasedBookID = 62, Long = "1 John", Short = "1Jo", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=1, OneBasedBookID = 63, Long = "2 John", Short = "2Jo", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=1, OneBasedBookID = 64, Long = "3 John", Short = "3Jo", Color = c, BookType = b, Testament = t });
			this.Add (new Book {Chapters=1, OneBasedBookID = 65, Long = "Jude", Short = "Jud", Color = c, BookType = b, Testament = t });
			
			b = BookType.Prophetic;
			c = UIColor.FromRGB (255, 255, 255);
			this.Add (new Book {Chapters=22, OneBasedBookID = 66, Long = "Revelation", Short = "Rev", Color = c, BookType = b, Testament = t });
			  
		}

		public Book GetBook (int zeroBasedSelectedBook)
		{ 
			var q = (from b in this
				where b.ZeroBasedBookID == zeroBasedSelectedBook
				select b).First ();
			
			return q;
		}
	}
}
